#include  <cmath>
#include  <cstdio>

int main(int argc, char *argv[])
{
	int n,e;
	scanf("%d%d",&n,&e);
	int sum = 0,p;
	while( n-- )
	{
		scanf("%d",&p);
		if(e%2 == 1 && p < 0 )
			continue;
		sum += pow(p,e);
	}
	printf("%d\n",sum);
}
